<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <title>Document</title>
    <style>
        div{
            width:300px;
            align-items: center;
            float:left;
        }
        button{
            width: 100px;
            background-color: gray;
            height: 50px;
            border: none;float:left
        }
       span{
        display: block;
        width: 100px;
        float:left;
        text-align: center;
        font-size: 30px;
        line-height: 50px;
       }
    </style>
</head>
<body>
    <div class="input_num">
        <button @click="sub">-</button>
        <span>{{num}}</span>
        <button @click="add">+</button>
    </div>
    <script>
        var app=new Vue({
            el:".input_num",
            data:{
                num:1
            },
            methods:{
                add:function(){
                    if(this.num<10){
                        this.num++;
                    }else
                    {
                        alert("超出上限")
                    }
                },
                sub:function(){
                    if(this.num>1){
                        this.num--;
                    }else
                    {
                        alert("超出下限")
                    }
                }
            }
        })
    </script>
</body>
</html>